<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
    <script>
        setInterval(show,1000)
        function show(){
            var app = document.getElementById("app")
            var s = "2021:10:14,18:00:00"
            var arr = s.split(",");
            var list = s.split(",")[0].replace(/\:/g,"-");
            arr[0]=list;
            var res = arr.join(" ");
            console.log(res)
            var startTime = new Date().getTime();
            var endTime = new Date(res).getTime();
            var gapTime = (endTime-startTime)/1000;
            console.log(gapTime)
            var d = Math.floor(gapTime/60/60/24);
            var h = Math.floor(gapTime/60/60%24);
            var m = Math.floor(gapTime/60%60);
            var s = Math.floor(gapTime%60);
            var sum = handleTime(d)+":"+handleTime(h)+":"+handleTime(m)+":"+handleTime(s);
            console.log(sum);
            app.innerHTML = sum;
        }
        function handleTime(num){
            if(num<10){
                num = "0"+num;
            }
            return num;
        }
    </script>
</body>
</html>